home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / msdos / config.c < prev    next >
C/C++ Source or Header  |  2000-04-25  |  22KB  |  615 lines

  1. /*
  2.  * Configuration routines.
  3.  *
  4.  * 19971219 support for mame.cfg by Valerio Verrando
  5.  * 19980402 moved out of msdos.c (N.S.), generalized routines (BW)
  6.  * 19980917 added a "-cheatfile" option (misc) in MAME.CFG      JCK
  7.  */
  8.  
  9. #include "mamalleg.h"
  10. #include "driver.h"
  11. #include <ctype.h>
  12. /* types of monitors supported */
  13. #include "monitors.h"
  14. /* from main() */
  15. extern int ignorecfg;
  16.  
  17. /* from video.c */
  18. extern int frameskip,autoframeskip;
  19. extern int scanlines, use_tweaked, video_sync, wait_vsync, use_triplebuf;
  20. extern int stretch, use_mmx, use_dirty;
  21. extern int vgafreq, always_synced, skiplines, skipcolumns;
  22. extern float osd_gamma_correction;
  23. extern int gfx_mode, gfx_width, gfx_height;
  24.  
  25. extern int monitor_type;
  26.  
  27. extern unsigned char tw224x288_h, tw224x288_v;
  28. extern unsigned char tw240x256_h, tw240x256_v;
  29. extern unsigned char tw256x240_h, tw256x240_v;
  30. extern unsigned char tw256x256_h, tw256x256_v;
  31. extern unsigned char tw256x256_hor_h, tw256x256_hor_v;
  32. extern unsigned char tw288x224_h, tw288x224_v;
  33. extern unsigned char tw240x320_h, tw240x320_v;
  34. extern unsigned char tw320x240_h, tw320x240_v;
  35. extern unsigned char tw336x240_h, tw336x240_v;
  36. extern unsigned char tw384x224_h, tw384x224_v;
  37. extern unsigned char tw384x240_h, tw384x240_v;
  38. extern unsigned char tw384x256_h, tw384x256_v;
  39. extern unsigned char tw400x256_h, tw400x256_v;
  40.  
  41.  
  42. /* Tweak values for 15.75KHz arcade/ntsc/pal modes */
  43. /* from video.c */
  44. extern unsigned char tw224x288arc_h, tw224x288arc_v, tw288x224arc_h, tw288x224arc_v;
  45. extern unsigned char tw256x256arc_h, tw256x256arc_v, tw256x240arc_h, tw256x240arc_v;
  46. extern unsigned char tw320x240arc_h, tw320x240arc_v, tw320x256arc_h, tw320x256arc_v;
  47. extern unsigned char tw352x240arc_h, tw352x240arc_v, tw352x256arc_h, tw352x256arc_v;
  48. extern unsigned char tw368x224arc_h, tw368x224arc_v;
  49. extern unsigned char tw368x240arc_h, tw368x240arc_v, tw368x256arc_h, tw368x256arc_v;
  50. extern unsigned char tw512x224arc_h, tw512x224arc_v, tw512x256arc_h, tw512x256arc_v;
  51. extern unsigned char tw512x448arc_h, tw512x448arc_v, tw512x512arc_h, tw512x512arc_v;
  52. extern unsigned char tw640x480arc_h, tw640x480arc_v;
  53.  
  54.  
  55. /* from sound.c */
  56. extern int soundcard, usestereo,attenuation;
  57.  
  58. /* from input.c */
  59. extern int use_mouse, joystick, use_hotrod;
  60.  
  61. /* from cheat.c */
  62. extern char *cheatfile;
  63.  
  64. /* from datafile.c */
  65. extern char *history_filename,*mameinfo_filename;
  66.  
  67. /* from fileio.c */
  68. void decompose_rom_sample_path (char *rompath, char *samplepath);
  69. extern char *nvdir, *hidir, *cfgdir, *inpdir, *stadir, *memcarddir;
  70. extern char *artworkdir, *screenshotdir, *alternate_name;
  71.  
  72. #ifdef MESS
  73. /* path to the CRC database files */
  74. char *crcdir;
  75. #endif
  76.  
  77. /* from video.c, for centering tweaked modes */
  78. extern int center_x;
  79. extern int center_y;
  80.  
  81. /*from video.c flag for 15.75KHz modes (req. for 15.75KHz Arcade Monitor Modes)*/
  82. extern int arcade_mode;
  83.  
  84. /*from svga15kh.c flag to allow delay for odd/even fields for interlaced displays (req. for 15.75KHz Arcade Monitor Modes)*/
  85. extern int wait_interlace;
  86.  
  87. static int mame_argc;
  88. static char **mame_argv;
  89. static int game;
  90. char *rompath, *samplepath;
  91.  
  92. struct { char *name; int id; } joy_table[] =
  93. {
  94.     { "none",               JOY_TYPE_NONE },
  95.     { "auto",               JOY_TYPE_AUTODETECT },
  96.     { "standard",           JOY_TYPE_STANDARD },
  97.     { "dual",               JOY_TYPE_2PADS },
  98.     { "4button",            JOY_TYPE_4BUTTON },
  99.     { "6button",            JOY_TYPE_6BUTTON },
  100.     { "8button",            JOY_TYPE_8BUTTON },
  101.     { "fspro",              JOY_TYPE_FSPRO },
  102.     { "wingex",             JOY_TYPE_WINGEX },
  103.     { "sidewinder",         JOY_TYPE_SIDEWINDER },
  104.     { "gamepadpro",         JOY_TYPE_GAMEPAD_PRO },
  105.     { "grip",               JOY_TYPE_GRIP },
  106.     { "grip4",              JOY_TYPE_GRIP4 },
  107.     { "sneslpt1",           JOY_TYPE_SNESPAD_LPT1 },
  108.     { "sneslpt2",           JOY_TYPE_SNESPAD_LPT2 },
  109.     { "sneslpt3",           JOY_TYPE_SNESPAD_LPT3 },
  110.     { "psxlpt1",            JOY_TYPE_PSXPAD_LPT1 },
  111.     { "psxlpt2",            JOY_TYPE_PSXPAD_LPT2 },
  112.     { "psxlpt3",            JOY_TYPE_PSXPAD_LPT3 },
  113.     { "n64lpt1",            JOY_TYPE_N64PAD_LPT1 },
  114.     { "n64lpt2",            JOY_TYPE_N64PAD_LPT2 },
  115.     { "n64lpt3",            JOY_TYPE_N64PAD_LPT3 },
  116.     { "wingwarrior",        JOY_TYPE_WINGWARRIOR },
  117.     { "segaisa",            JOY_TYPE_IFSEGA_ISA },
  118.     { "segapci",            JOY_TYPE_IFSEGA_PCI },
  119.     { 0, 0 }
  120. } ;
  121.  
  122.  
  123.  
  124. /* monitor type */
  125. struct { char *name; int id; } monitor_table[] =
  126. {
  127.     { "standard",   MONITOR_TYPE_STANDARD},
  128.     { "ntsc",       MONITOR_TYPE_NTSC},
  129.     { "pal",                MONITOR_TYPE_PAL},
  130.     { "arcade",             MONITOR_TYPE_ARCADE},
  131.     { NULL, NULL }
  132. } ;
  133.  
  134.  
  135. /*
  136.  * gets some boolean config value.
  137.  * 0 = false, >0 = true, <0 = auto
  138.  * the shortcut can only be used on the commandline
  139.  */
  140. static int get_bool (char *section, char *option, char *shortcut, int def)
  141. {
  142.     char *yesnoauto;
  143.     int res, i;
  144.  
  145.     res = def;
  146.  
  147.     if (ignorecfg) goto cmdline;
  148.  
  149.     /* look into mame.cfg, [section] */
  150.     if (def == 0)
  151.         yesnoauto = get_config_string(section, option, "no");
  152.     else if (def > 0)
  153.         yesnoauto = get_config_string(section, option, "yes");
  154.     else /* def < 0 */
  155.         yesnoauto = get_config_string(section, option, "auto");
  156.  
  157.     /* if the option doesn't exist in the cfgfile, create it */
  158.     if (get_config_string(section, option, "#") == "#")
  159.         set_config_string(section, option, yesnoauto);
  160.  
  161.     /* look into mame.cfg, [gamename] */
  162.     yesnoauto = get_config_string((char *)drivers[game]->name, option, yesnoauto);
  163.  
  164.     /* also take numerical values instead of "yes", "no" and "auto" */
  165.     if      (stricmp(yesnoauto, "no"  ) == 0) res = 0;
  166.     else if (stricmp(yesnoauto, "yes" ) == 0) res = 1;
  167.     else if (stricmp(yesnoauto, "auto") == 0) res = -1;
  168.     else    res = atoi (yesnoauto);
  169.  
  170. cmdline:
  171.     /* check the commandline */
  172.     for (i = 1; i < mame_argc; i++)
  173.     {
  174.         if (mame_argv[i][0] != '-') continue;
  175.         /* look for "-option" */
  176.         if (stricmp(&mame_argv[i][1], option) == 0)
  177.             res = 1;
  178.         /* look for "-shortcut" */
  179.         if (shortcut && (stricmp(&mame_argv[i][1], shortcut) == 0))
  180.             res = 1;
  181.         /* look for "-nooption" */
  182.         if (strnicmp(&mame_argv[i][1], "no", 2) == 0)
  183.         {
  184.             if (stricmp(&mame_argv[i][3], option) == 0)
  185.                 res = 0;
  186.             if (shortcut && (stricmp(&mame_argv[i][3], shortcut) == 0))
  187.                 res = 0;
  188.         }
  189.         /* look for "-autooption" */
  190.         if (strnicmp(&mame_argv[i][1], "auto", 4) == 0)
  191.         {
  192.             if (stricmp(&mame_argv[i][5], option) == 0)
  193.                 res = -1;
  194.             if (shortcut && (stricmp(&mame_argv[i][5], shortcut) == 0))
  195.                 res = -1;
  196.         }
  197.     }
  198.     return res;
  199. }
  200.  
  201. static int get_int (char *section, char *option, char *shortcut, int def)
  202. {
  203.     int res,i;
  204.  
  205.     res = def;
  206.  
  207.     if (!ignorecfg)
  208.     {
  209.         /* if the option does not exist, create it */
  210.         if (get_config_int (section, option, -777) == -777)
  211.             set_config_int (section, option, def);
  212.  
  213.         /* look into mame.cfg, [section] */
  214.         res = get_config_int (section, option, def);
  215.  
  216.         /* look into mame.cfg, [gamename] */
  217.         res = get_config_int ((char *)drivers[game]->name, option, res);
  218.     }
  219.  
  220.     /* get it from the commandline */
  221.     for (i = 1; i < mame_argc; i++)
  222.     {
  223.         if (mame_argv[i][0] != '-')
  224.             continue;
  225.         if ((stricmp(&mame_argv[i][1], option) == 0) ||
  226.             (shortcut && (stricmp(&mame_argv[i][1], shortcut ) == 0)))
  227.         {
  228.             i++;
  229.             if (i < mame_argc) res = atoi (mame_argv[i]);
  230.         }
  231.     }
  232.     return res;
  233. }
  234.  
  235. static float get_float (char *section, char *option, char *shortcut, float def)
  236. {
  237.     int i;
  238.     float res;
  239.  
  240.     res = def;
  241.  
  242.     if (!ignorecfg)
  243.     {
  244.         /* if the option does not exist, create it */
  245.         if (get_config_float (section, option, 9999.0) == 9999.0)
  246.             set_config_float (section, option, def);
  247.  
  248.         /* look into mame.cfg, [section] */
  249.         res = get_config_float (section, option, def);
  250.  
  251.         /* look into mame.cfg, [gamename] */
  252.         res = get_config_float ((char *)drivers[game]->name, option, res);
  253.     }
  254.  
  255.     /* get it from the commandline */
  256.     for (i = 1; i < mame_argc; i++)
  257.     {
  258.         if (mame_argv[i][0] != '-')
  259.             continue;
  260.         if ((stricmp(&mame_argv[i][1], option) == 0) ||
  261.             (shortcut && (stricmp(&mame_argv[i][1], shortcut ) == 0)))
  262.         {
  263.             i++;
  264.             if (i < mame_argc) res = atof (mame_argv[i]);
  265.         }
  266.     }
  267.     return res;
  268. }
  269.  
  270. static char *get_string (char *section, char *option, char *shortcut, char *def)
  271. {
  272.     char *res;
  273.     int i;
  274.  
  275.     res = def;
  276.  
  277.     if (!ignorecfg)
  278.     {
  279.         /* if the option does not exist, create it */
  280.         if (get_config_string (section, option, "#") == "#" )
  281.             set_config_string (section, option, def);
  282.  
  283.         /* look into mame.cfg, [section] */
  284.         res = get_config_string(section, option, def);
  285.  
  286.         /* look into mame.cfg, [gamename] */
  287.         res = get_config_string((char*)drivers[game]->name, option, res);
  288.     }
  289.  
  290.     /* get it from the commandline */
  291.     for (i = 1; i < mame_argc; i++)
  292.     {
  293.         if (mame_argv[i][0] != '-')
  294.             continue;
  295.  
  296.         if ((stricmp(&mame_argv[i][1], option) == 0) ||
  297.             (shortcut && (stricmp(&mame_argv[i][1], shortcut)  == 0)))
  298.         {
  299.             i++;
  300.             if (i < mame_argc) res = mame_argv[i];
  301.         }
  302.     }
  303.     return res;
  304. }
  305.  
  306. void get_rom_sample_path (int argc, char **argv, int game_index)
  307. {
  308.     int i;
  309.  
  310.     alternate_name = 0;
  311.     mame_argc = argc;
  312.     mame_argv = argv;
  313.     game = game_index;
  314.  
  315.     rompath    = get_string ("directory", "rompath",    NULL, ".;ROMS");
  316.     samplepath = get_string ("directory", "samplepath", NULL, ".;SAMPLES");
  317.  
  318.     /* handle '-romdir' hack. We should get rid of this BW */
  319.     alternate_name = 0;
  320.     for (i = 1; i < argc; i++)
  321.     {
  322.         if (stricmp (argv[i], "-romdir") == 0)
  323.         {
  324.             i++;
  325.             if (i < argc) alternate_name = argv[i];
  326.         }
  327.     }
  328.  
  329.     /* decompose paths into components (handled by fileio.c) */
  330.     decompose_rom_sample_path (rompath, samplepath);
  331. }
  332.  
  333. /* for playback of .inp files */
  334. void init_inpdir(void)
  335. {
  336.     inpdir = get_string ("directory", "inp",     NULL, "INP");
  337. }
  338.  
  339. void parse_cmdline (int argc, char **argv, int game_index)
  340. {
  341.     static float f_beam, f_flicker;
  342.     char *resolution;
  343.     char *vesamode;
  344.     char *joyname;
  345.     char tmpres[10];
  346.     int i;
  347.     char *tmpstr;
  348.     char *monitorname;
  349.  
  350.     mame_argc = argc;
  351.     mame_argv = argv;
  352.     game = game_index;
  353.  
  354.  
  355.     /* force third mouse button emulation to "no" otherwise Allegro will default to "yes" */
  356.     set_config_string(0,"emulate_three","no");
  357.  
  358.     /* read graphic configuration */
  359.     scanlines   = get_bool   ("config", "scanlines",    NULL,  1);
  360.     stretch     = get_bool   ("config", "stretch",        NULL,  1);
  361.     options.use_artwork = get_bool   ("config", "artwork",    NULL,  1);
  362.     options.use_samples = get_bool   ("config", "samples",    NULL,  1);
  363.     video_sync  = get_bool   ("config", "vsync",        NULL,  0);
  364.     wait_vsync  = get_bool   ("config", "waitvsync",    NULL,  0);
  365.     use_triplebuf = get_bool ("config", "triplebuffer",    NULL,  0);
  366.     use_tweaked = get_bool   ("config", "tweak",        NULL,  0);
  367.     vesamode    = get_string ("config", "vesamode",    NULL,    "vesa3");
  368.     use_mmx        = get_bool   ("config", "mmx",         NULL,    -1);
  369.     use_dirty    = get_bool     ("config", "dirty",    NULL,    -1);
  370.     options.antialias   = get_bool   ("config", "antialias",    NULL,  1);
  371.     options.translucency = get_bool    ("config", "translucency", NULL, 1);
  372.  
  373.     vgafreq     = get_int    ("config", "vgafreq",      NULL,  -1);
  374.     always_synced = get_bool ("config", "alwayssynced", NULL, 0);
  375.  
  376.     tmpstr             = get_string ("config", "depth", NULL, "auto");
  377.     options.color_depth = atoi(tmpstr);
  378.     if (options.color_depth != 8 && options.color_depth != 16) options.color_depth = 0;    /* auto */
  379.  
  380.     skiplines   = get_int    ("config", "skiplines",    NULL, 0);
  381.     skipcolumns = get_int    ("config", "skipcolumns",  NULL, 0);
  382.     f_beam      = get_float  ("config", "beam",         NULL, 1.0);
  383.     if (f_beam < 1.0) f_beam = 1.0;
  384.     if (f_beam > 16.0) f_beam = 16.0;
  385.     f_flicker   = get_float  ("config", "flicker",      NULL, 0.0);
  386.     if (f_flicker < 0.0) f_flicker = 0.0;
  387.     if (f_flicker > 100.0) f_flicker = 100.0;
  388.     osd_gamma_correction = get_float ("config", "gamma",   NULL, 1.0);
  389.     if (osd_gamma_correction < 0.5) osd_gamma_correction = 0.5;
  390.     if (osd_gamma_correction > 2.0) osd_gamma_correction = 2.0;
  391.  
  392.     tmpstr             = get_string ("config", "frameskip", "fs", "auto");
  393.     if (!stricmp(tmpstr,"auto"))
  394.     {
  395.         frameskip = 0;
  396.         autoframeskip = 1;
  397.     }
  398.     else
  399.     {
  400.         frameskip = atoi(tmpstr);
  401.         autoframeskip = 0;
  402.     }
  403.     options.norotate  = get_bool ("config", "norotate",  NULL, 0);
  404.     options.ror       = get_bool ("config", "ror",       NULL, 0);
  405.     options.rol       = get_bool ("config", "rol",       NULL, 0);
  406.     options.flipx     = get_bool ("config", "flipx",     NULL, 0);
  407.     options.flipy     = get_bool ("config", "flipy",     NULL, 0);
  408.  
  409.     /* read sound configuration */
  410.     soundcard           = get_int  ("config", "soundcard",  NULL, -1);
  411.     options.use_emulated_ym3812 = !get_bool ("config", "ym3812opl",  NULL,  0);
  412.     options.samplerate = get_int  ("config", "samplerate", "sr", 22050);
  413.     if (options.samplerate < 5000) options.samplerate = 5000;
  414.     if (options.samplerate > 50000) options.samplerate = 50000;
  415.     usestereo           = get_bool ("config", "stereo",  NULL,  1);
  416.     attenuation         = get_int  ("config", "volume",  NULL,  0);
  417.     if (attenuation < -32) attenuation = -32;
  418.     if (attenuation > 0) attenuation = 0;
  419.  
  420.     /* read input configuration */
  421.     use_mouse = get_bool   ("config", "mouse",   NULL,  1);
  422.     joyname   = get_string ("config", "joystick", "joy", "none");
  423.     use_hotrod = 0;
  424.     if (get_bool  ("config", "hotrod",   NULL,  0)) use_hotrod = 1;
  425.     if (get_bool  ("config", "hotrodse",   NULL,  0)) use_hotrod = 2;
  426.  
  427.     /* misc configuration */
  428.     options.cheat      = get_bool ("config", "cheat", NULL, 0);
  429.     options.mame_debug = get_bool ("config", "debug", NULL, 0);
  430.     cheatfile  = get_string ("config", "cheatfile", "cf", "CHEAT.DAT");    /* JCK 980917 */
  431.  
  432.      #ifndef MESS
  433.      history_filename  = get_string ("config", "historyfile", NULL, "HISTORY.DAT");    /* JCK 980917 */
  434.      #else
  435.      history_filename  = get_string ("config", "historyfile", NULL, "SYSINFO.DAT");
  436.      #endif
  437.  
  438.     mameinfo_filename  = get_string ("config", "mameinfofile", NULL, "MAMEINFO.DAT");    /* JCK 980917 */
  439.  
  440.     /* get resolution */
  441.     resolution  = get_string ("config", "resolution", NULL, "auto");
  442.  
  443.     /* set default subdirectories */
  444.     nvdir      = get_string ("directory", "nvram",   NULL, "NVRAM");
  445.     hidir      = get_string ("directory", "hi",      NULL, "HI");
  446.     cfgdir     = get_string ("directory", "cfg",     NULL, "CFG");
  447.     screenshotdir = get_string ("directory", "snap",     NULL, "SNAP");
  448.     memcarddir = get_string ("directory", "memcard", NULL, "MEMCARD");
  449.     stadir     = get_string ("directory", "sta",     NULL, "STA");
  450.     artworkdir = get_string ("directory", "artwork", NULL, "ARTWORK");
  451.      #ifdef MESS
  452.         crcdir = get_string ("directory", "crc", NULL, "CRC");
  453.      #endif
  454.  
  455.     tmpstr = get_string ("config", "language", NULL, "english");
  456.     options.language_file = osd_fopen(0,tmpstr,OSD_FILETYPE_LANGUAGE,0);
  457.  
  458.  
  459.     /* get tweaked modes info */
  460.     tw224x288_h            = get_int ("tweaked", "224x288_h",              NULL, 0x5f);
  461.     tw224x288_v         = get_int ("tweaked", "224x288_v",              NULL, 0x54);
  462.     tw240x256_h     = get_int ("tweaked", "240x256_h",              NULL, 0x67);
  463.     tw240x256_v     = get_int ("tweaked", "240x256_v",              NULL, 0x23);
  464.     tw256x240_h     = get_int ("tweaked", "256x240_h",              NULL, 0x55);
  465.     tw256x240_v     = get_int ("tweaked", "256x240_v",              NULL, 0x43);
  466.     tw256x256_h     = get_int ("tweaked", "256x256_h",              NULL, 0x6c);
  467.     tw256x256_v     = get_int ("tweaked", "256x256_v",              NULL, 0x23);
  468.     tw256x256_hor_h = get_int ("tweaked", "256x256_hor_h",  NULL, 0x55);
  469.     tw256x256_hor_v = get_int ("tweaked", "256x256_hor_v",  NULL, 0x60);
  470.     tw288x224_h     = get_int ("tweaked", "288x224_h",              NULL, 0x5f);
  471.     tw288x224_v     = get_int ("tweaked", "288x224_v",              NULL, 0x0c);
  472.     tw240x320_h             = get_int ("tweaked", "240x320_h",              NULL, 0x5a);
  473.     tw240x320_v             = get_int ("tweaked", "240x320_v",              NULL, 0x8c);
  474.     tw320x240_h             = get_int ("tweaked", "320x240_h",              NULL, 0x5f);
  475.     tw320x240_v             = get_int ("tweaked", "320x240_v",              NULL, 0x0c);
  476.     tw336x240_h             = get_int ("tweaked", "336x240_h",              NULL, 0x5f);
  477.     tw336x240_v             = get_int ("tweaked", "336x240_v",              NULL, 0x0c);
  478.     tw384x224_h             = get_int ("tweaked", "384x224_h",              NULL, 0x6c);
  479.     tw384x224_v             = get_int ("tweaked", "384x224_v",              NULL, 0x0c);
  480.     tw384x240_h             = get_int ("tweaked", "384x240_h",              NULL, 0x6c);
  481.     tw384x240_v             = get_int ("tweaked", "384x240_v",              NULL, 0x0c);
  482.     tw384x256_h             = get_int ("tweaked", "384x256_h",              NULL, 0x6c);
  483.     tw384x256_v             = get_int ("tweaked", "384x256_v",              NULL, 0x23);
  484.  
  485.     /* Get 15.75KHz tweak values */
  486.     tw224x288arc_h          = get_int ("tweaked", "224x288arc_h",   NULL, 0x5d);
  487.     tw224x288arc_v          = get_int ("tweaked", "224x288arc_v",   NULL, 0x38);
  488.     tw288x224arc_h          = get_int ("tweaked", "288x224arc_h",   NULL, 0x5d);
  489.     tw288x224arc_v          = get_int ("tweaked", "288x224arc_v",   NULL, 0x09);
  490.     tw256x240arc_h          = get_int ("tweaked", "256x240arc_h",   NULL, 0x5d);
  491.     tw256x240arc_v          = get_int ("tweaked", "256x240arc_v",   NULL, 0x09);
  492.     tw256x256arc_h          = get_int ("tweaked", "256x256arc_h",   NULL, 0x5d);
  493.     tw256x256arc_v          = get_int ("tweaked", "256x256arc_v",   NULL, 0x17);
  494.     tw320x240arc_h          = get_int ("tweaked", "320x240arc_h",   NULL, 0x69);
  495.     tw320x240arc_v          = get_int ("tweaked", "320x240arc_v",   NULL, 0x09);
  496.     tw320x256arc_h          = get_int ("tweaked", "320x256arc_h",   NULL, 0x69);
  497.     tw320x256arc_v          = get_int ("tweaked", "320x256arc_v",   NULL, 0x17);
  498.     tw352x240arc_h          = get_int ("tweaked", "352x240arc_h",   NULL, 0x6a);
  499.     tw352x240arc_v          = get_int ("tweaked", "352x240arc_v",   NULL, 0x09);
  500.     tw352x256arc_h          = get_int ("tweaked", "352x256arc_h",   NULL, 0x6a);
  501.     tw352x256arc_v          = get_int ("tweaked", "352x256arc_v",   NULL, 0x17);
  502.     tw368x224arc_h          = get_int ("tweaked", "368x224arc_h",   NULL, 0x6a);
  503.     tw368x224arc_v          = get_int ("tweaked", "368x224arc_v",   NULL, 0x09);
  504.     tw368x240arc_h          = get_int ("tweaked", "368x240arc_h",   NULL, 0x6a);
  505.     tw368x240arc_v          = get_int ("tweaked", "368x240arc_v",   NULL, 0x09);
  506.     tw368x256arc_h          = get_int ("tweaked", "368x256arc_h",   NULL, 0x6a);
  507.     tw368x256arc_v          = get_int ("tweaked", "368x256arc_v",   NULL, 0x17);
  508.     tw512x224arc_h          = get_int ("tweaked", "512x224arc_h",   NULL, 0xbf);
  509.     tw512x224arc_v          = get_int ("tweaked", "512x224arc_v",   NULL, 0x09);
  510.     tw512x256arc_h          = get_int ("tweaked", "512x256arc_h",   NULL, 0xbf);
  511.     tw512x256arc_v          = get_int ("tweaked", "512x256arc_v",   NULL, 0x17);
  512.     tw512x448arc_h          = get_int ("tweaked", "512x448arc_h",   NULL, 0xbf);
  513.     tw512x448arc_v          = get_int ("tweaked", "512x448arc_v",   NULL, 0x09);
  514.     tw512x512arc_h          = get_int ("tweaked", "512x512arc_h",   NULL, 0xbf);
  515.     tw512x512arc_v          = get_int ("tweaked", "512x512arc_v",   NULL, 0x17);
  516.     tw640x480arc_h          = get_int ("tweaked", "640x480arc_h",   NULL, 0xc1);
  517.     tw640x480arc_v          = get_int ("tweaked", "640x480arc_v",   NULL, 0x09);
  518.  
  519.     /* this is handled externally cause the audit stuff needs it, too */
  520.     get_rom_sample_path (argc, argv, game_index);
  521.  
  522.     /* get the monitor type */
  523.     monitorname = get_string ("config", "monitor", NULL, "standard");
  524.     /* get -centerx */
  525.     center_x = get_int ("config", "centerx", NULL,  0);
  526.     /* get -centery */
  527.     center_y = get_int ("config", "centery", NULL,  0);
  528.     /* get -waitinterlace */
  529.     wait_interlace = get_bool ("config", "waitinterlace", NULL,  0);
  530.  
  531.     /* process some parameters */
  532.     options.beam = (int)(f_beam * 0x00010000);
  533.     if (options.beam < 0x00010000)
  534.         options.beam = 0x00010000;
  535.     if (options.beam > 0x00100000)
  536.         options.beam = 0x00100000;
  537.  
  538.     options.flicker = (int)(f_flicker * 2.55);
  539.     if (options.flicker < 0)
  540.         options.flicker = 0;
  541.     if (options.flicker > 255)
  542.         options.flicker = 255;
  543.  
  544.     if (stricmp (vesamode, "vesa1") == 0)
  545.         gfx_mode = GFX_VESA1;
  546.     else if (stricmp (vesamode, "vesa2b") == 0)
  547.         gfx_mode = GFX_VESA2B;
  548.     else if (stricmp (vesamode, "vesa2l") == 0)
  549.         gfx_mode = GFX_VESA2L;
  550.     else if (stricmp (vesamode, "vesa3") == 0)
  551.         gfx_mode = GFX_VESA3;
  552.     else
  553.     {
  554.         logerror("%s is not a valid entry for vesamode\n",
  555.                     vesamode);
  556.         gfx_mode = GFX_VESA3; /* default to VESA2L */
  557.     }
  558.  
  559.     /* any option that starts with a digit is taken as a resolution option */
  560.     /* this is to handle the old "-wxh" commandline option. */
  561.     for (i = 1; i < argc; i++)
  562.     {
  563.         if (argv[i][0] == '-' && isdigit(argv[i][1]) &&
  564.                 (strstr(argv[i],"x") || strstr(argv[i],"X")))
  565.             resolution = &argv[i][1];
  566.     }
  567.  
  568.     /* break up resolution into gfx_width and gfx_height */
  569.     gfx_height = gfx_width = 0;
  570.     if (stricmp (resolution, "auto") != 0)
  571.     {
  572.         char *tmp;
  573.         strncpy (tmpres, resolution, 10);
  574.         tmp = strtok (tmpres, "xX");
  575.         gfx_width = atoi (tmp);
  576.         tmp = strtok (0, "xX");
  577.         if (tmp)
  578.             gfx_height = atoi (tmp);
  579.     }
  580.  
  581.     /* convert joystick name into an Allegro-compliant joystick signature */
  582.     joystick = -2; /* default to invalid value */
  583.  
  584.     for (i = 0; joy_table[i].name != NULL; i++)
  585.     {
  586.         if (stricmp (joy_table[i].name, joyname) == 0)
  587.         {
  588.             joystick = joy_table[i].id;
  589.             logerror("using joystick %s = %08x\n",
  590.                         joyname,joy_table[i].id);
  591.             break;
  592.         }
  593.     }
  594.  
  595.     if (joystick == -2)
  596.     {
  597.         logerror("%s is not a valid entry for a joystick\n",
  598.                     joyname);
  599.         joystick = JOY_TYPE_NONE;
  600.     }
  601.  
  602.     /* get monitor type from supplied name */
  603.     monitor_type = MONITOR_TYPE_STANDARD; /* default to PC monitor */
  604.  
  605.     for (i = 0; monitor_table[i].name != NULL; i++)
  606.     {
  607.         if ((stricmp (monitor_table[i].name, monitorname) == 0))
  608.         {
  609.             monitor_type = monitor_table[i].id;
  610.             break;
  611.         }
  612.     }
  613. }
  614.  
  615.